var t = getApp();

Page({
    data: {
        histroyInfo: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        isShowNoHistory: ""
    },
    onLoad: function(t) {
        this._getData();
    },
    _getData: function(a) {
        var e = this;
        t._getNetWork({
            url: t.getNetAddresss("plugin.video-demand.api.video-demand-member.get-scan-history"),
            success: function(o) {
                if (console.log(o.data, "1111121132"), console.log(0 == o.data.data.length, "对"), 
                0 == o.data.data.length ? e.setData({
                    isShowNoHistory: !0
                }) : e.setData({
                    isShowNoHistory: !1
                }), console.log(e.data.isShowNoHistory, "判断"), 1 != o.data.result || t._isTextEmpty(o.data.data)) console.error(o); else {
                    var s = o.data.data;
                    e.setData({
                        histroyInfo: s.data,
                        total_page: s.last_page
                    }), a && a(o);
                }
            },
            fail: function(t) {
                console.error(t);
            }
        });
    },
    clearCourse: function() {
        var a = this;
        wx.showModal({
            title: "提示",
            content: "确认全部清除吗？",
            success: function(e) {
                e.confirm ? t._getNetWork({
                    url: t.getNetAddresss("plugin.video-demand.api.video-demand-member.historical-purge"),
                    success: function(t) {
                        1 == t.data.result ? (a.setData({
                            histroyInfo: []
                        }), wx.showToast({
                            icon: "none",
                            title: "清除成功",
                            duration: 1500
                        })) : console.error(t.data);
                    },
                    fail: function(t) {
                        console.error(t);
                    }
                }) : e.cancel && console.error(e);
            }
        });
    },
    toCourse: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    _getMoreData: function() {
        var a = this, e = t.getNetAddresss("plugin.video-demand.api.video-demand-member.get-scan-history");
        this.data.page >= this.data.total_page ? a.setData({
            isLoadMore: !1
        }) : (a.setData({
            page: this.data.page + 1
        }), e += "&page=" + a.data.page, t._getNetWork({
            url: e,
            success: function(t) {
                if (1 == t.data.result) {
                    var e = t.data.data;
                    a.setData({
                        isLoadMore: !0,
                        histroyInfo: a.data.histroyInfo.concat(e.data)
                    });
                } else a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    },
    onReady: function() {
        wx.setNavigationBarTitle({
            title: "观看历史"
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0
        }), this._getData();
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});